// src/server/http.js
import request from './request'

// GET 请求封装
export const get = (url, params = {}) => {
  return request({
    method: 'get',
    url,
    params // query 参数
  })
}

// POST 请求封装
export const post = (url, data = {}) => {
  return request({
    method: 'post',
    url,
    data // 请求体
  })
}

// PUT 请求（可选）
export const put = (url, data = {}) => {
  return request({
    method: 'put',
    url,
    data
  })
}

// DELETE 请求（可选）
export const del = (url) => {
  return request({
    method: 'delete',
    url
  })
}
export const upload = (url, formData) => {
  return request({
    method: 'post',
    url,
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}
// 更新图片
export const uploadCover = (url, formData) => {
  return request({
    method: 'post',
    url,
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 你也可以导出 request 实例本身，用于复杂请求
export { request }